package com.solarroast.mirrorarray.gui.listeners;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import com.solarroast.mirrorarray.SolarRoastConstants;
import com.solarroast.mirrorarray.components.MirrorArray;
import com.solarroast.mirrorarray.components.MirrorArrayItem;
import com.solarroast.mirrorarray.gui.MirrorArrayItemWindow;

public class MAIPopupClickListener implements MouseListener, SolarRoastConstants {
	private MirrorArrayItem mAItem;
	private MirrorArray mArray;
	private String type;
	private static MirrorArrayItemWindow mAIWindow;
	
	public MAIPopupClickListener(MirrorArrayItem mAItem, MirrorArray mArray, String type) {
		this.mAItem = mAItem;
		this.mArray = mArray;
		this.type = type;
	}
	
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		if(type.equalsIgnoreCase(POPUP_ACTIVATE)) {
			System.out.println(mAItem.getName() + " - ACTIVATE ALL");
			//mAItem.toggleMirrorsActive(true);
			mArray.setActiveMAIs(true);
		}
		else if(type.equalsIgnoreCase(POPUP_DEACTIVATE)) {
			System.out.println(mAItem.getName() + " - DEACTIVATE ALL");
			//mAItem.toggleMirrorsActive(false);
			mArray.setActiveMAIs(false);
		}
		else if(type.equalsIgnoreCase(POPUP_MODIFY)) {
			if(mAIWindow != null) {
				mAIWindow.setMirrorArray(mAItem.getArray());
				mAIWindow.redraw();
			}
			else {
				mAIWindow = new MirrorArrayItemWindow("Status");
				mAIWindow.setMirrorArray(mAItem.getArray());
				mAIWindow.redraw();
			}
		}
	}
	
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}
	
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
	public void mouseEntered(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	
	public void mouseClicked(MouseEvent arg0) {
		// TODO Auto-generated method stub
	}
}
